<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/taglib/jstl.jsp" %>

<c:set var="isRevise" value="${false}"/>
<c:set var="styleRevise" value="" />
<c:if test="${not empty fnInfo}">
	<c:set var="isRevise" value="${true}"/>
	<c:set var="styleRevise" value="style='background-color:#E3E3E3;' readonly='readonly'" />
</c:if>
<div style="margin:2px 2px 2px 2px;">
	<form id="frmFnReg">
		<table class="left-table">
		<tr>
			<td class="fnTitleTd">코드 (명칭)</td>
			<td class="fnContsTd">
				<select id="codeTypes">
					<option value="" selected="selected">- 타입 선택 -</option>
					
					<c:forEach var="items" items="${codeTypes}" varStatus="i">
						<c:choose>
							<c:when test="${not empty enCodeType && not empty enCodeTypeStatus}">
								<c:choose>
									<c:when test="${enCodeTypeStatus eq 'true'}">
										<c:if test="${enCodeType eq items.cdTpId}">
											<option value="${items.cdTpId}"
												<c:if test="${isRevise && (fnInfo.cdTpId eq items.cdTpId)}"> selected="selected" </c:if>
											>${items.cdTpId} (${items.cdTpAlias})</option>
										</c:if>
									</c:when>
									
									<c:otherwise>
										<c:if test="${enCodeType ne items.cdTpId}">
											<option value="${items.cdTpId}"
												<c:if test="${isRevise && (fnInfo.cdTpId eq items.cdTpId)}"> selected="selected" </c:if>
											>${items.cdTpId} (${items.cdTpAlias})</option>
										</c:if>
									</c:otherwise>
								</c:choose>
							</c:when>
							
							<c:otherwise>
								<option value="${items.cdTpId}"
									<c:if test="${isRevise && (fnInfo.cdTpId eq items.cdTpId)}"> selected="selected" </c:if>
								>${items.cdTpId} (${items.cdTpAlias})</option>
							</c:otherwise>
						</c:choose>
					</c:forEach>
				</select>
				
				<select id="fnId" name="fnId"><option value="" selected="selected">- 코드 선택 -</option></select>
				<c:if test="${isRevise}">
					<input type="hidden" id="cdId" name="cdId" value="${fnInfo.fnId}" />
				</c:if>
			</td>
		</tr>
		<tr>
			<td class="fnTitleTd">기능 이름</td>
			<td class="fnContsTd">
				<div>
					<div style="float:left;"><input type="text" id="fnAlias" name="fnAlias" value="${fnInfo.fnAlias}" /></div>
					<div style="float:left; margin:1px 0 0 0;">&nbsp;&nbsp;&nbsp;&nbsp;&gt;&gt;&gt;&nbsp;Highest Level in group:</div>
					<div style="float:left; margin:2px 0 0 0;">
						<c:set var="fnIsParentYN" value="" />
						<c:if test="${fnInfo.fnHighestLevlYN eq 'Y'}">
							<c:set var="fnHighestLevlYN" value="checked='checked'" />
						</c:if>
						<input type="checkbox" 
							style="top:10px;" id="fnHighestLevlYN" name="fnHighestLevlYN" value="Y" ${fnHighestLevlYN} />
					</div>
					
					<div style="clear:both;"></div>
				</div>
			</td>
		</tr>
		<tr>
			<td class="fnTitleTd">URL</td>
			<td class="fnContsTd"><input type="text" id="fnServletUrl" name="fnServletUrl" style="width:365px;" 
				value="${fnInfo.fnServletUrl}" /></td>
		</tr>
		<tr>
			<td class="fnTitleTd">활성화 옵션</td>
			<td class="fnContsTd">
				<div style="float:left; width:10px;">&nbsp;</div>
			
				<div style="float:left; text-indent: 0px; 
							width:160px; margin:3px 0 3px 0; border:1px solid gray;">
				
					<div style="clear:both;"></div>
					<div style="width:100%; height:18px; line-height:18px; background-color:#D2D2D2; 
								color:#666666; text-align:center; font-weight:normal;">사용 여부</div>
						
					<div style="margin:1px 0 0 10px; padding:10px 0 10px 0; width:100%;">
						<c:set var="fnUseY" value="checked='checked'" />
						<c:set var="fnUseN" value="" />
						<c:if test="${isRevise && fnInfo.fnUseYN == 'N'}">
							<c:set var="fnUseY" value="" />
							<c:set var="fnUseN" value="checked='checked'" />
						</c:if>
						
						<div style="float:left;"><input type="radio" name="fnUseYN" value="Y" ${fnUseY} /></div>
						<div style="float:left;">Y</div>
						<div style="float:left; width:20px;">&nbsp;</div>
						<div style="float:left;"><input type="radio" name="fnUseYN" value="N" ${fnUseN} /></div>
						<div style="float:left;">N</div>
						
						<div style="clear:both;"></div>
					</div>
				</div>
				
				<div style="float:left; width:10px;">&nbsp;</div>
				
				<div style="float:left; text-indent: 0px; 
							width:192px; height:98px; margin:3px 0 3px 0; border:1px solid gray;">
							
					<div style="clear:both;"></div>
					<div style="width:100%; height:18px; line-height:18px; background-color:#D2D2D2; 
								color:#666666; text-align:center; font-weight:normal;">Private Group 설정</div>
						
					<div style="margin:1px 0 0 0; overflow-y:scroll; overflow-x:hidden; width:100%; height:78px;">
						
						<c:choose>
							<c:when test="${not empty privateGrpLst}">
								<c:forEach var="item" items="${privateGrpLst}" varStatus="i">
								<div style="margin:3px 0 0 3px;">
									<div style="float:left;">
										<input type="checkbox" name="items[${i.index}].grpId" value="${item.grpId}" 
											<c:if test="${item.privateGrpFnYN eq 'Y'}"> checked="checked" </c:if> />
									</div>
									<div style="float:left;">&nbsp;${item.grpAlias}</div>
									<div style="clear:both;"></div>
								</div>
								
								<c:if test="${not i.last}">
									<div style="width:100%; height:1px; border:1px dotted #D2D2D2;"></div>
								</c:if>
								</c:forEach>
							</c:when>
							<c:otherwise><div style="margin:3px 0 0 0;">설정할 수 있는 그룹이 없습니다.</div></c:otherwise>
						</c:choose>
						
					</div>
				</div>
				
				<div style="clear:both;"></div>
			</td>
		</tr>
		<tr>
			<td class="fnTitleTd" style="height:86px;">설명</td>
			<td class="fnContsTd">
				<textarea id="fnDesc" name="fnDesc" style="width:95%; height:80px; resize:none;">${fnInfo.fnDesc}</textarea>
			</td>
		</tr>
		</table>
	</form>
</div>
<div class="fnBtnsDiv">
	<c:choose>
	<c:when test="${isRevise}"><input type="button" id="jqwFormReviseSaveBtn" value="수정" /></c:when>
	<c:otherwise><input type="button" id="jqwFormSaveBtn" value="저장" /></c:otherwise>
	</c:choose>

	<input type="button" id="jqwCloseBtn" value="닫기" />
</div>

<script type="text/javascript" src="/resources/js/views/template/system/function/_regForm.js"></script>
<script type="text/javascript" src="/resources/js/views/template/system/function/_regFormValid.js"></script>